{extend name="mainadmin@layouts/base" /}
{block name="main" }

<header class="header  b-b clearfix">
    <form id="forms" class="talbe-search form-inline "  method="post" action="{:url('getList')}" >
        <div class="page-breadcrumbs">
            <ul class="breadcrumb" >
                <li>
                    <i class="fa fa-ellipsis-v"></i>
                    <strong>代理商品列表</strong>
                </li>
            </ul>
            <select name="cat_id"  style="width: 150px;" data-notsearch="true" data-toggle="select2"  data-chang="submit">
                <option value="">所有分类</option>
                {$classListOpt|raw}
            </select>
            <select name="status" style="width: 100px;" data-notsearch="true" data-toggle="select2"  data-chang="submit">
                <option value="-1">状态</option>
                <option value="1">上架中</option>
                <option value="2">未上架</option>
            </select>

            <input type="text" class="form-control input-large" value="{$search.keyword}" name="keyword" placeholder="商品名称/SN" data-rule-required="true" />
            <button class="btn btn-sm btn-default-iq" type="submit" title="搜索"><i class="fa fa-search"></i></button>
            <a href="javascript:;" data-remote="{:url('selectGoods')}" data-toggle="ajaxModal" title="添加商品" class="btn btn-sm btn-default fr m-t-md m-r"><i class="fa fa-plus m-r-xs"></i>添加代理商品</a>
        </div>
    </form>
</header>

<section class="scrollable wrapper w-f ">
    <section class="panel panel-default ">
        <div class="table-responsive " id="list_box">
            {include file="sys_admin/goods/list" /}
        </div>
    </section>
</section>
<script type="text/javascript">
    function searchGoods(select_type){
        var arr = new Object();
        arr.keyword = $('#'+select_type+'_keyword').val();
        arr.min_search = 1;
        arr.is_dividend = {$is_dividend|intval};
        $('#'+select_type+'_select').html('<option value="">选择商品</option>');
        var res = jq_ajax('{:url("shop/sys_admin.goods/pubSearch")}',arr);
        $.each(res.list, function(i,value){
            $('#'+select_type+'_select').append('<option value="'+value.goods_id+'" data-goods_sn="'+value.goods_sn+'">'+value.goods_name+'</option>');
        })
    }
    //选择商品，跳转
    function goAdd(){
        var select_goods_id = $('#shop_goods_select').val();
        if (select_goods_id < 1){
            return _alert('请选择商品.',true);
        }
        jq_ajax('{:url("selectGoods")}','goods_id='+select_goods_id,function (res) {
            if (res.code == 0){
                return _alert(res.msg,true);
            }
            window.location.href = '{:_url("info",["sel_goods_id"=>"【select_goods_id】"])}';
        });
    }
</script>
{/block}
